﻿<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->
<UserControl x:Class="System.Windows.Controls.Samples.ValidationSummarySample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"
    Loaded="UserControl_Loaded">
    <Grid Background="White">
        <StackPanel Width="450">
            <ContentControl Content="ValidationSummary" Style="{StaticResource Header}" HorizontalAlignment="Stretch" />
            <TextBlock Text="To see the ValidationSummary, try setting the Phone field to an invalid phone number." Margin="4" Style="{StaticResource Information}" />
            <dataInput:ValidationSummary Margin="4" />
            <Grid x:Name="contactGrid" Width="450">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <Rectangle Stroke="Black" StrokeThickness="2" Grid.Column="0" Grid.RowSpan="9" Grid.ColumnSpan="3" />

                <dataInput:Label Margin="4" Target="{Binding ElementName=firstName}" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right" Content="First Name" />
                <TextBox x:Name="firstName" Text="{Binding FirstName, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="0" Grid.Column="1" Margin="4" />
                <dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=firstName}" Grid.Row="0" Grid.Column="2" />

                <dataInput:Label Margin="4" Target="{Binding ElementName=lastName}" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="0" />
                <TextBox x:Name="lastName" Text="{Binding LastName, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="1" Grid.Column="1" Margin="4" />
                <dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=lastName}" Grid.Row="1" Grid.Column="2" Description="Last name of the contact" />

                <dataInput:Label Margin="4" Target="{Binding ElementName=phone}" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="0" />
                <TextBox x:Name="phone" Text="{Binding Phone, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="2" Grid.Column="1" Margin="4" />
                <dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=phone}" Grid.Row="2" Grid.Column="2" />

                <dataInput:Label Margin="4" Target="{Binding ElementName=street1}" HorizontalAlignment="Right" Grid.Row="3" Grid.Column="0" />
                <TextBox x:Name="street1" Text="{Binding Street1, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="3" Grid.Column="1" Margin="4" />
                <dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=street1}" Grid.Row="3" Grid.Column="2" />

                <dataInput:Label Margin="4" Target="{Binding ElementName=street2}" HorizontalAlignment="Right" Grid.Row="4" Grid.Column="0" />
                <TextBox x:Name="street2" Text="{Binding Street2, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="4" Grid.Column="1" Margin="4" />
                <dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=street2}" Grid.Row="4" Grid.Column="2" />

                <dataInput:Label Margin="4" Target="{Binding ElementName=city}" HorizontalAlignment="Right" Grid.Row="5" Grid.Column="0" />
                <TextBox x:Name="city" Text="{Binding City, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="5" Grid.Column="1" Margin="4" />
                <dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=city}" Grid.Row="5" Grid.Column="2" />

                <dataInput:Label Margin="4" Target="{Binding ElementName=state}" HorizontalAlignment="Right" Grid.Row="6" Grid.Column="0" />
                <TextBox x:Name="state" Text="{Binding State, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="6" Grid.Column="1" Margin="4" />
                <dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=state}" Grid.Row="6" Grid.Column="2" />

                <dataInput:Label Margin="4" Target="{Binding ElementName=zip}" HorizontalAlignment="Right" Grid.Row="7" Grid.Column="0" />
                <TextBox x:Name="zip" Text="{Binding Zip, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="7" Grid.Column="1" Margin="4" />
                <dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=zip}" Grid.Row="7" Grid.Column="2" />

                <dataInput:Label Margin="4" Target="{Binding ElementName=email}" HorizontalAlignment="Right" Grid.Row="8" Grid.Column="0" />
                <TextBox x:Name="email" Text="{Binding Email, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="8" Grid.Column="1" Margin="4" />
                <dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=email}" Grid.Row="8" Grid.Column="2" />
            </Grid>
        </StackPanel>
        <src:SourceViewer xmlns:src="clr-namespace:System.Windows.Controls.Samples;assembly=System.Windows.Controls.Samples.Common" xmlns:sys="clr-namespace:System;assembly=mscorlib">
  <src:SourceFile Path="ValidationSummarySample.xaml">
    <src:SourceFile.Source>
      <sys:String>&lt;!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
--&gt;
&lt;UserControl x:Class="System.Windows.Controls.Samples.ValidationSummarySample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"
    Loaded="UserControl_Loaded"&gt;
    &lt;Grid Background="White"&gt;
        &lt;StackPanel Width="450"&gt;
            &lt;ContentControl Content="ValidationSummary" Style="{StaticResource Header}" HorizontalAlignment="Stretch" /&gt;
            &lt;TextBlock Text="To see the ValidationSummary, try setting the Phone field to an invalid phone number." Margin="4" Style="{StaticResource Information}" /&gt;
            &lt;dataInput:ValidationSummary Margin="4" /&gt;
            &lt;Grid x:Name="contactGrid" Width="450"&gt;
                &lt;Grid.ColumnDefinitions&gt;
                    &lt;ColumnDefinition Width="Auto" /&gt;
                    &lt;ColumnDefinition /&gt;
                    &lt;ColumnDefinition Width="Auto" /&gt;
                    &lt;ColumnDefinition Width="Auto" /&gt;
                &lt;/Grid.ColumnDefinitions&gt;
                &lt;Grid.RowDefinitions&gt;
                    &lt;RowDefinition /&gt;
                    &lt;RowDefinition /&gt;
                    &lt;RowDefinition /&gt;
                    &lt;RowDefinition /&gt;
                    &lt;RowDefinition /&gt;
                    &lt;RowDefinition /&gt;
                    &lt;RowDefinition /&gt;
                    &lt;RowDefinition /&gt;
                    &lt;RowDefinition /&gt;
                &lt;/Grid.RowDefinitions&gt;

                &lt;Rectangle Stroke="Black" StrokeThickness="2" Grid.Column="0" Grid.RowSpan="9" Grid.ColumnSpan="3" /&gt;

                &lt;dataInput:Label Margin="4" Target="{Binding ElementName=firstName}" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right" Content="First Name" /&gt;
                &lt;TextBox x:Name="firstName" Text="{Binding FirstName, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="0" Grid.Column="1" Margin="4" /&gt;
                &lt;dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=firstName}" Grid.Row="0" Grid.Column="2" /&gt;

                &lt;dataInput:Label Margin="4" Target="{Binding ElementName=lastName}" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="0" /&gt;
                &lt;TextBox x:Name="lastName" Text="{Binding LastName, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="1" Grid.Column="1" Margin="4" /&gt;
                &lt;dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=lastName}" Grid.Row="1" Grid.Column="2" Description="Last name of the contact" /&gt;

                &lt;dataInput:Label Margin="4" Target="{Binding ElementName=phone}" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="0" /&gt;
                &lt;TextBox x:Name="phone" Text="{Binding Phone, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="2" Grid.Column="1" Margin="4" /&gt;
                &lt;dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=phone}" Grid.Row="2" Grid.Column="2" /&gt;

                &lt;dataInput:Label Margin="4" Target="{Binding ElementName=street1}" HorizontalAlignment="Right" Grid.Row="3" Grid.Column="0" /&gt;
                &lt;TextBox x:Name="street1" Text="{Binding Street1, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="3" Grid.Column="1" Margin="4" /&gt;
                &lt;dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=street1}" Grid.Row="3" Grid.Column="2" /&gt;

                &lt;dataInput:Label Margin="4" Target="{Binding ElementName=street2}" HorizontalAlignment="Right" Grid.Row="4" Grid.Column="0" /&gt;
                &lt;TextBox x:Name="street2" Text="{Binding Street2, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="4" Grid.Column="1" Margin="4" /&gt;
                &lt;dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=street2}" Grid.Row="4" Grid.Column="2" /&gt;

                &lt;dataInput:Label Margin="4" Target="{Binding ElementName=city}" HorizontalAlignment="Right" Grid.Row="5" Grid.Column="0" /&gt;
                &lt;TextBox x:Name="city" Text="{Binding City, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="5" Grid.Column="1" Margin="4" /&gt;
                &lt;dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=city}" Grid.Row="5" Grid.Column="2" /&gt;

                &lt;dataInput:Label Margin="4" Target="{Binding ElementName=state}" HorizontalAlignment="Right" Grid.Row="6" Grid.Column="0" /&gt;
                &lt;TextBox x:Name="state" Text="{Binding State, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="6" Grid.Column="1" Margin="4" /&gt;
                &lt;dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=state}" Grid.Row="6" Grid.Column="2" /&gt;

                &lt;dataInput:Label Margin="4" Target="{Binding ElementName=zip}" HorizontalAlignment="Right" Grid.Row="7" Grid.Column="0" /&gt;
                &lt;TextBox x:Name="zip" Text="{Binding Zip, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="7" Grid.Column="1" Margin="4" /&gt;
                &lt;dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=zip}" Grid.Row="7" Grid.Column="2" /&gt;

                &lt;dataInput:Label Margin="4" Target="{Binding ElementName=email}" HorizontalAlignment="Right" Grid.Row="8" Grid.Column="0" /&gt;
                &lt;TextBox x:Name="email" Text="{Binding Email, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Grid.Row="8" Grid.Column="1" Margin="4" /&gt;
                &lt;dataInput:DescriptionViewer Margin="4" Target="{Binding ElementName=email}" Grid.Row="8" Grid.Column="2" /&gt;
            &lt;/Grid&gt;
        &lt;/StackPanel&gt;
    &lt;/Grid&gt;
&lt;/UserControl&gt;
</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="ValidationSummarySample.xaml.cs">
    <src:SourceFile.Source>
      <sys:String>// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System.ComponentModel;

namespace System.Windows.Controls.Samples
{
    /// &lt;summary&gt;
    /// Sample page demonstrating the ValidationSummary.
    /// &lt;/summary&gt;
    [Sample("ValidationSummary", DifficultyLevel.Intermediate)]
    [Category("Validation")]
    public partial class ValidationSummarySample : UserControl
    {
        /// &lt;summary&gt;
        /// Initializes an ValidationSummarySample.
        /// &lt;/summary&gt;
        public ValidationSummarySample()
        {
            InitializeComponent();
        }

        /// &lt;summary&gt;
        /// Initializes the data after loading.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;This control.&lt;/param&gt;
        /// &lt;param name="e"&gt;Event arguments.&lt;/param&gt;
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Used by event defined in Xaml.")]
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            contactGrid.DataContext = Contact.JohnDoe;
        }
    }
}
</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="ValidationSummarySample.xaml.vb">
    <src:SourceFile.Source>
      <sys:String>' (c) Copyright Microsoft Corporation.
' This source is subject to the Microsoft Public License (Ms-PL).
' Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
' All other rights reserved.

Imports System.ComponentModel

''' &lt;summary&gt;
''' Sample page demonstrating the ValidationSummary.
''' &lt;/summary&gt;
&lt;Sample("ValidationSummary", DifficultyLevel.Intermediate)&gt; _
&lt;Category("Validation")&gt; _
Public Class ValidationSummarySample
    Inherits UserControl

    ''' &lt;summary&gt;
    ''' Initializes an ValidationSummarySample.
    ''' &lt;/summary&gt;
    Public Sub New()
        InitializeComponent()
    End Sub

    ''' &lt;summary&gt;
    ''' Initializes the data after loading.
    ''' &lt;/summary&gt;
    ''' &lt;param name="sender"&gt;This control.&lt;/param&gt;
    ''' &lt;param name="e"&gt;Event arguments.&lt;/param&gt;
    &lt;Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification:="Used by event defined in Xaml.")&gt; _
    Private Sub UserControl_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
        contactGrid.DataContext = Contact.JohnDoe
    End Sub
End Class
</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
</src:SourceViewer>
    </Grid>
</UserControl>
